﻿Imports System.Data.OleDb
Imports DTO
Public Class MuonSach_ChiTietMuonSachDAO

    Public Function LayDSPMS_CTPMSTheoMaDocGia(ByVal maDocGia As Integer) As List(Of MuonSach_ChiTietMuonSachDTO)
        DataProvider.OpenConnecttion()
        Dim sql As String = "SELECT PHIEUMUONSACH.MaPhieuMuon, PHIEUMUONSACH.NgayMuon, PHIEUMUONSACH.MaDocGia, "
        sql = sql & " PHIEUMUONSACH.MaChiTietPhieuMuon, CHITIETPHIEUMUONSACH.MaSach ,CHITIETPHIEUMUONSACH.MaTheLoai, CHITIETPHIEUMUONSACH.MaTacGia"
        sql = sql & " FROM PHIEUMUONSACH INNER JOIN CHITIETPHIEUMUONSACH ON PHIEUMUONSACH.MaChiTietPhieuMuon = CHITIETPHIEUMUONSACH.MaChiTietPhieuMuonSach "
        sql = sql & " WHERE (((PHIEUMUONSACH.MaDocGia)= " & maDocGia.ToString() & ")); "


        Dim reader As OleDbDataReader
        reader = DataProvider.ExecSelect(sql)

        Dim ds As New List(Of MuonSach_ChiTietMuonSachDTO)
        While reader.Read()
            Dim item As New MuonSach_ChiTietMuonSachDTO
            item.MaPhieuMuon = reader("MaPhieuMuon")
            item.NgayMuon = reader.GetDateTime(1)
            item.MaDocGia = reader.GetInt32(2)
            item.MaChiTietPhieuMuon = reader.GetInt32(3)
            item.MaSach = reader.GetInt32(4)
            item.MaLoaiSach = reader.GetInt32(5)
            item.MaTacGia = reader.GetInt32(6)
            ds.Add(item)
        End While
        DataProvider.CloseConnect()

        Return ds
    End Function
End Class
